-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(time-select): [time-select] refactor the theme #2275
Conversation
WalkthroughThe changes in this pull request focus on the time select component's styling, specifically in the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (9)
packages/theme/src/time-select/vars.less (8)
15-15
: Approved: Updated variable name and value.The renaming of
--ti-time-select-item-text-color
to--ti-Time-Select-item-text-color
aligns with the new naming convention. The use ofvar(--tv-color-act-primary-text)
as the value may improve theme consistency.Consider updating the comment to reflect the new naming convention:
// Time Select item text color
17-17
: Approved: Updated variable name and value.The renaming of
--ti-time-select-item-font-size
to--ti-Time-Select-item-font-size
aligns with the new naming convention. The use ofvar(--tv-font-size-md)
as the value may improve theme consistency.Consider updating the comment to reflect the new naming convention:
// Time Select item font size
19-19
: Approved: Updated variable name and value.The renaming of
--ti-time-select-item-padding-horizontal
to--ti-Time-Select-item-padding-horizontal
aligns with the new naming convention. The use ofvar(--tv-space-xl)
as the value may improve theme consistency.Consider updating the comment to reflect the new naming convention:
// Time Select item horizontal padding
21-21
: Approved: Updated variable name and value.The renaming of
--ti-time-select-item-hover-bg-color
to--ti-Time-Select-item-hover-bg-color
aligns with the new naming convention. The use ofvar(--tv-color-bg-hover)
as the value may improve theme consistency.Consider updating the comment to reflect the new naming convention:
// Time Select item hover background color
23-23
: Approved: Updated variable name and value.The renaming of
--ti-time-select-item-disabled-text-color
to--ti-Time-Select-item-disabled-text-color
aligns with the new naming convention. The use ofvar(--tv-color-text-disabled)
as the value may improve theme consistency.Consider updating the comment to reflect the new naming convention:
// Time Select item disabled text color
25-25
: Approved with suggestions: Updated variable name and value.The renaming of
--ti-time-select-item-select-hover-bg-color
to--ti-Time-Select-item-select-hover-bg-color
aligns with the new naming convention. The use ofvar(--tv-color-bg-active)
as the value may improve theme consistency.
- Consider updating the comment to reflect the new naming convention:
// Time Select selected item hover background color
- Consider renaming the variable to use "active" instead of "select" to match the value:
--ti-Time-Select-item-active-hover-bg-color: var(--tv-color-bg-active);This would make the variable name more consistent with the value it's using.
27-27
: Approved with suggestions: Updated variable name and value.The renaming of
--ti-time-select-item-selected-text-color
to--ti-Time-Select-item-selected-text-color
aligns with the new naming convention. The use ofvar(--tv-color-text-active)
as the value may improve theme consistency.
- Consider updating the comment to reflect the new naming convention:
// Time Select selected item text color
- Consider renaming the variable to use "active" instead of "selected" to match the value:
--ti-Time-Select-item-active-text-color: var(--tv-color-text-active);This would make the variable name more consistent with the value it's using.
Line range hint
1-29
: Overall assessment: Improved theme consistency with minor suggestions.The changes in this file consistently apply a new naming convention for variables and utilize more generic theme variables, which should improve overall theme consistency and maintainability.
To further improve the file:
- Update all comments to reflect the new naming convention (e.g., "Time Select" instead of "时间选择").
- Ensure comments accurately describe the purpose of each variable (especially for the content padding variable).
- Consider using "active" instead of "selected" or "select" in variable names where the corresponding value uses "active".
- Translate all comments to English for consistency with other comments in the codebase.
These minor adjustments will enhance the clarity and consistency of the theme variables.
packages/theme/src/time-select/index.less (1)
32-36
: Approve variable name changes, but reconsider fixed values for line height and height.The update to use new variable names prefixed with
ti-Time-Select-
is consistent with the refactoring effort and improves naming clarity. However, the use of fixed values for line height and height might reduce flexibility.Consider using variables for line height and height:
- line-height: 32px; - height: 32px; + line-height: var(--ti-Time-Select-item-line-height, 32px); + height: var(--ti-Time-Select-item-height, 32px);This approach maintains consistency with other properties while allowing for easy theming and providing default values.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- packages/theme/src/time-select/index.less (1 hunks)
- packages/theme/src/time-select/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (4)
packages/theme/src/time-select/vars.less (1)
13-13
: Improved function naming convention.The renaming of the function from
.component-css-vars-time-select()
to.inject-Time-Select-vars()
is a positive change. It follows a more consistent naming convention using PascalCase for the component name and accurately describes the action of injecting these variables into the global scope.packages/theme/src/time-select/index.less (3)
40-41
: Approve the updated variable names for selected, hover, and disabled states.The changes to use new, more specific variable names for the selected, hover, and disabled states are consistent with the overall refactoring effort. These updates improve clarity and maintain a consistent naming convention throughout the component.
Also applies to: 45-45, 50-50
58-58
: Approve the updated variable name for content padding.The change to use the new variable name
--ti-Time-Select-content-padding-top
for the content's top padding is consistent with the overall refactoring effort. This update improves clarity and maintains a consistent naming convention.
21-21
: Approve the updated CSS variable injection method.The change from
.component-css-vars-time-select()
to.inject-Time-Select-vars()
improves naming consistency and clarity. This appears to be part of a larger refactoring effort.To ensure this change doesn't break other parts of the codebase, please run the following script:
✅ Verification successful
CSS variable injection method verified successfully.
The old method
.component-css-vars-time-select
is no longer present in the codebase, and the new method.inject-Time-Select-vars()
is correctly defined invars.less
and used inindex.less
.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any remaining usage of the old method name # Test: Search for the old method name. Expect: No results. rg --type less "component-css-vars-time-select" # Test: Verify the new method is defined. Expect: Definition found. rg --type less "inject-Time-Select-vars"Length of output: 230
--ti-time-select-scrollbar-height: 242px; | ||
--ti-time-select-scrollbar-wrap-max-height: unset; | ||
--ti-time-select-content-padding-top: var(--ti-common-space-2x, 8px); | ||
--ti-Time-Select-content-padding-top: var(--tv-space-md); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with suggestions: Updated variable name and value.
The renaming of --ti-time-select-content-padding-top
to --ti-Time-Select-content-padding-top
aligns with the new naming convention. The use of var(--tv-space-md)
as the value may improve theme consistency.
The comment "面板高度" (panel height) is inconsistent with the variable's purpose, which is to set the top padding of the content.
- Update the comment to accurately reflect the variable's purpose:
// Time Select content top padding
- Consider translating the comment to English for consistency with other comments in the file.
height: 242px; | ||
.@{time-select-scrollbar-cls} { | ||
height: var(--ti-time-select-scrollbar-height); | ||
height: 242px; | ||
.@{css-prefix}scrollbar__wrap { | ||
max-height: var(--ti-time-select-scrollbar-wrap-max-height); | ||
max-height: unset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reconsider using fixed height values and 'unset'.
The changes from variable references to fixed height values (242px) and 'unset' for max-height raise some concerns:
- Fixed values reduce flexibility and make it harder to maintain consistent theming across the application.
- The 'unset' value for max-height might affect the component's behavior in different contexts.
Consider reverting to using variables for these properties to maintain flexibility and consistency.
Suggested changes:
- height: 242px;
+ height: var(--ti-Time-Select-height, 242px);
- height: 242px;
+ height: var(--ti-Time-Select-scrollbar-height, 242px);
- max-height: unset;
+ max-height: var(--ti-Time-Select-scrollbar-wrap-max-height, none);
This approach allows for easy theming while providing default values.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
height: 242px; | |
.@{time-select-scrollbar-cls} { | |
height: var(--ti-time-select-scrollbar-height); | |
height: 242px; | |
.@{css-prefix}scrollbar__wrap { | |
max-height: var(--ti-time-select-scrollbar-wrap-max-height); | |
max-height: unset; | |
height: var(--ti-Time-Select-height, 242px); | |
.@{time-select-scrollbar-cls} { | |
height: var(--ti-Time-Select-scrollbar-height, 242px); | |
.@{css-prefix}scrollbar__wrap { | |
max-height: var(--ti-Time-Select-scrollbar-wrap-max-height, none); |
// 时间选择选项字体色 | ||
--ti-time-select-item-text-color: var(--ti-common-color-text-primary, #191919); | ||
--ti-Time-Select-item-text-color: var(--tv-color-act-primary-text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个组件应该写成 --tv-TimeSelect
// 时间选择选项字体色 | ||
--ti-time-select-item-text-color: var(--ti-common-color-text-primary, #191919); | ||
--tv-TimeSelect-item-text-color: var(--tv-color-act-primary-text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不是像button那样的交互类组件,所以用这个变量是不准确的,应该用:--tv-color-text
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
Bug Fixes
Documentation